//
//  TagButton.m
//  XPhoto
//
//  Created by sentinel on 2020/4/20.
//  Copyright © 2020 baboy. All rights reserved.
//

#import "UIButton+tag.h"

@implementation UIButton(tag)


+ (UIButton *)buttonWithTag:(NSString *)tag image:(UIImage *_Nullable)image{
    CGRect frame = CGRectMake(0,0, 0, TAG_BUTTON_HEIGHT);
    UIButton *btn = [[UIButton alloc] initWithFrame:frame];
    btn.imageView.contentMode = UIViewContentModeScaleAspectFit;
    btn.contentEdgeInsets = UIEdgeInsetsMake(0, 6, 0, 6);
    [btn setImage:image forState:UIControlStateNormal];
    [btn setTitle:tag forState:UIControlStateNormal];
    btn.titleLabel.font = THEME_TAG_BTN_TITLE_FONT;
    [btn setTitleColor:THEME_TAG_BTN_TITLE_COLOR forState:UIControlStateNormal];
    [btn setTitleColor:THEME_TAG_BTN_SELECTED_TITLE_COLOR forState:UIControlStateSelected];
    btn.backgroundColor = THEME_TAG_BTN_BG_COLOR;
    btn.clipsToBounds = YES;
    btn.layer.cornerRadius = TAG_BUTTON_HEIGHT/2;
    btn.layer.borderWidth = 1.0f;
    btn.layer.borderColor = [THEME_TAG_BTN_BORDER_COLOR CGColor];
//    btn.userInteractionEnabled = NO;
    btn.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
    [btn sizeToFit];
    frame = btn.frame;
    frame.size.height = TAG_BUTTON_HEIGHT;
    btn.frame = frame;    
    return btn;
}

@end
